package com.syl.proxy.bean;

import com.syl.proxy.interfaces.OverrideRule;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
 * @author syl
 * @create 2019-08-06 19:01
 **/
@Setter
@Getter
@ToString
@NoArgsConstructor
@Accessors(chain = true)
public class MappingRule {
    /**
     * 匹配规则
     */
    private String match;
    /**
     * 目标地址
     *
     */
    private String targetUri;
    /**
     * 最后请求的url是否包含匹配规则
     * 和nginx 的情况类似详见
     * https://blog.csdn.net/saga_gallon/article/details/81300921
     */
    private boolean overlookMatch;
    /**
     * 设置指定uri才会进入覆盖结果接口
     */
    private String matchOverrideUri;
    /**
     * 覆盖结果接口
     */
    private OverrideRule overrideRule;

    public MappingRule(String match, OverrideRule overrideRule) {
        this.match = match;
        this.overrideRule = overrideRule;
    }

    public MappingRule(String match, String targetUri, boolean overlookMatch) {
        this.match = match;
        this.targetUri = targetUri;
        this.overlookMatch = overlookMatch;
    }

    public MappingRule(String match, String targetUri, boolean overlookMatch, String matchOverrideUri, OverrideRule overrideRule) {
        this.match = match;
        this.targetUri = targetUri;
        this.overlookMatch = overlookMatch;
        this.matchOverrideUri = matchOverrideUri;
        this.overrideRule = overrideRule;
    }

}
